#ifndef _ACCUMULATOR_H_
#define _ACCUMULATOR_H_
#include "..\StudyEXP\Date.h"


class Accumulator
{
public:
	Accumulator(const Date& dt, double val):lastDate(dt),value(val),sum(0){}
	double getSum(const Date& dt) const
	{
		return sum + value * (dt-lastDate);
	}
	void change(const Date& dt, double val)
	{
		sum = getSum(dt);
		lastDate = dt;
		value = val;
	}
	void reset(const Date& dt, double val)
	{
		lastDate = dt;
		value = val;
		sum = 0;
	}
private:
	Date lastDate;
	double value, sum;
};
#endif
